<template>
    <view class="commonLayout">
        <view>提款人：{{pageData.userName}}</view>
        <view>提款金额：{{(pageData.amount * 100).toFixed(2)}} 元</view>
        <view>提款时间：{{timestampToDate(pageData.updateTime)}}</view>
    </view>
</template>
<script setup>
    import api from '@/utils/api.js';
    import { timestampToDate } from '@/utils/util';
    import { reactive } from 'vue';
    import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';

    let pageData = reactive({});

    const getDetail = async (orderId) => {
        await api.withdrawOrderDetail({orderId: orderId}).then(res => {
            pageData = Object.assign(pageData, res.data);
        });
    }
    onLoad((options) => {
        getDetail(options.orderId);
    })

    // 分享给朋友
    onShareAppMessage(() => {
        // 使用路由参数
        const pages = getCurrentPages();
        const currentPage = pages[pages.length - 1];
        const orderId = currentPage.options?.orderId;
        
        return {
            title: '提现详情 - 飞手之家',
            path: orderId ? `/pages/withdrawalDetail/withdrawalDetail?orderId=${orderId}` : '/pages/withdrawalDetail/withdrawalDetail',
            imageUrl: '/static/images/head.jpg'
        };
    });

    // 分享到朋友圈
    onShareTimeline(() => {
        // 使用路由参数
        const pages = getCurrentPages();
        const currentPage = pages[pages.length - 1];
        const orderId = currentPage.options?.orderId;
        
        return {
            title: '提现详情 - 飞手之家',
            query: orderId ? `orderId=${orderId}` : '',
            imageUrl: '/static/images/head.jpg'
        };
    });
</script>
<style lang="scss">

</style>